<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2024/12/26
 * Time: 14:04
 */

namespace app\model\home;


class Nav extends Base
{
    protected $append = [
        'status_text'
    ];

    protected $globalScope = ['website_id'];

    public function scopeWebsiteId($query){
        global $wid;
        $query->where('website_id',$wid);
    }

    public function website(){
        return $this->hasOne(Website::class,'website_id','id');
    }

    public function son(){
        return $this->hasMany(Nav::class,'pid','id');
    }

    public function getStatusTextAttr($value,$data){
        $array = [
            1 => '正常',
            2 => '不显示'
        ];
        return $array[$data['status']];
    }
}